<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="../static/jquery-easyui-1.5.5.3/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="../static/jquery-easyui-1.5.5.3/themes/bootstrap/easyui.css"/>
<link rel="stylesheet" type="text/css" href="../static/jquery-easyui-1.5.5.3/themes/icon.css"/>
<script type="text/javascript" src="../static/jquery-easyui-1.5.5.3/jquery.easyui.min.js"></script>
<script type="text/javascript" src="../static/jquery-easyui-1.5.5.3/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript">
$(function(){
	$("#t_user").datagrid({
		idField: 'id',
		title: '用户列表',
		width: '100%',
		fitColumns: true,
		striped: true,
		loadMsg: '数据正在加载...',
		rownumbers: true,
		url: 'list1',
		frozenColumns: [
			[
				{     
					field: 'ck',
					width: 50,
					checkbox: true
				}
			]
		],
		columns: [
			[
				{
					field: 'number',
					title: '发票号码',
					width: 100,
					align: 'center'
				},{
					field: 'code',
					title: '发票代码',
					width: 150,
					align: 'center'
				},{
					field: 'money',
					title: '金额',
					width: 150,
					align: 'center'
				},{
					field: 'date',
					title: '开票时间',
					width: 150,
					align: 'center'
				},{
					field: 'name',
					title: '报销人',
					width: 150,
					align: 'center'
				},{
					field: 'endDate',
					title: '报销时间',
					width: 150,
					align: 'center'
				},{
					field: 'Unit',
					title: '开票单位',
					width: 100,
					align: 'center',
					formatter: function(value, rec){ 
						return rec.lessee.name;
					}
				},{
					field: 'state',
					title: '状态',
					width: 150,
					align: 'center'
				}
			]
		],
		pagination: true,
		pageSize: 10,
		pageList: [3, 5, 10, 20],
		toolbar: [
			{
				text: '删除电子发票',
				iconCls: 'icon-remove',
				handler: function(){
					var arr = $('#t_user').datagrid('getSelections');
					if(arr.length <= 0){
						$.messager.show({
							title: '提示信息',
							msg: '至少选中一行记录进行删除！'
						});
					}else{
						$.messager.confirm('提示信息', '确认删除'+arr.length+'条数据？', function(r){
							if(r){
								var ids = '';
								for(var i = 0; i < arr.length; i++){
									ids += arr[i].id + ',';
								}
								ids = ids.substring(0, ids.length-1); 
								
								$.post('delete', {ids: ids}, function(){
									$('#t_user').datagrid('reload');
									$('#t_user').datagrid('unselectAll');
									$.messager.show({
										title: '提示信息',
										msg: '操作成功！'
									});
								});
							}else{
								return ;
							}
						});
					}
				}
			}
		]
	});
});
</script>
</head>
<body>
	<table id = "t_user"></table>
</body>
</html>